<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>教师管理系统</title>
    <link rel="stylesheet" href="../static/layui/css/layui.css">
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo" style="display: flex; flex-direction: column; justify-content: center; height: 60px; padding: 5px 0;">
                <div style="line-height: 30px;font-size: 16px;">教师管理系统</div>
                <div id="userInfo" style="font-size: 14px; line-height: 20px;"></div>
            </div>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item"><a href="http://localhost:63342/StudentManageSystem-Thymeleaf/templates/login.html">退出</a></li>
            </ul>
        </div>
        
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <ul class="layui-nav layui-nav-tree">
                    <li class="layui-nav-item">
                        <a href="javascript:;" data-url="http://localhost:63342/StudentManageSystem-Thymeleaf/templates/course/list.html" class="site-menu">课程管理</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;" data-url="http://localhost:63342/StudentManageSystem-Thymeleaf/templates/grade/list.html" class="site-menu">成绩管理</a>
                    </li>
                </ul>
            </div>
        </div>
        
        <div class="layui-body">
            <iframe src="" frameborder="0" id="mainFrame" style="width: 100%; height: 100%;"></iframe>
        </div>
    </div>

    <script src="../static/layui/layui.js"></script>
    <script>
        layui.use(['element'], function(){
            var element = layui.element;
            var $ = layui.$;

            // 设置全局 Ajax 默认值
            $.ajaxSetup({
                xhrFields: {
                    withCredentials: true
                },
                crossDomain: true
            });

            // 获取当前登录老师信息
            $.ajax({
                url: 'http://localhost:8050/api/backend/user/current',
                type: 'GET',
                success: function(res) {
                    if (res.code === 200) {
                        $('#userInfo').text(res.data.userName  + ' [' + res.data.code + ']');
                    }
                }
            });
            

            
            $('.site-menu').on('click', function(){
                var url = $(this).data('url');
                $('#mainFrame').attr('src', url);
            });
        });
    </script>
</body>
</html> 